package com.fhc.usb

import android.hardware.usb.UsbDevice


data class UsbDeviceDto(
    val deviceId: Int,
    val deviceName: String,
    val deviceProtocol: Int,
    val productName: String?,
    val productId: Int,
    val manufacturerName: String?,
    val configurationCount: Int,
    val serialNumber: String?,
    val vendorId: Int,
    var online: Boolean = true,
) {
    //  deviceId:1002  deviceName:/dev/bus/usb/001/002  deviceProtocol:0
    //  productName:CP2102N USB to UART Bridge Controller
    //  productId:60000 manufacturerName:Silicon Labs configurationCount:1 serialNumber:46ab11271bb4eb11863f92d8bbbaf228 vendorId:4292
    companion object {
        fun from(device: UsbDevice?) = if(device== null) null else UsbDeviceDto(
            device.deviceId,
            device.deviceName,
            device.deviceProtocol,
            device.productName,
            device.productId,
            device.manufacturerName,
            device.configurationCount,
            device.serialNumber,
            device.vendorId
        )
    }
}